const { screen, ipcMain } = require('electron');

module.exports = function (win) {
	// 打开控制台
	ipcMain.on('opendevtools', (e) => {
		win.webContents.openDevTools();
	});

	// 进入登录页
	ipcMain.on('inLoginPage', async (e) => {
		await win.hide();
		setTimeout(async () => {
			await win.setResizable(true);
			await win.setSize(877, 535);
			await win.setResizable(false);
			await win.center();
			await win.show();
		}, 500);
	});

	// 离开登录页
	ipcMain.on('leaveLoginPage', async (e) => {
		await win.hide();
		setTimeout(async () => {
			const { width, height } = screen.getPrimaryDisplay().workAreaSize;
			!win.isFullScreen() && win.setSize(928, 659);
			// win.setSize(parseInt((width / 10) * 8), parseInt((height / 10) * 8));
			await win.setMinimumSize(parseInt((width / 10) * 6), parseInt((height / 10) * 6));
			await win.setResizable(true);
			await win.center();
			await win.show();
		}, 500);
	});
};
